
CC = gcc
INCLUDE = -I. -I/usr/local/dao/include -Iwrap
LIB = -L. -L/usr/lib
CFLAG = -c -fPIC
LFLAG = -lGL -lGLU

TARGET = DaoOpenGL.so

DIR_INPUT =
DIR_INC =

UNAME = $(shell uname)

ifeq ($(UNAME), Linux)
  CFLAG += -DUNIX
  LFLAG += -fPIC -shared -Wl,-soname,libDaoOpenGL.so
  INCLUDE += -I/usr/include/GL
  DIR_INPUT =/usr/include/GL
  DIR_INC = dir_inc=GL
endif

ifeq ($(UNAME), Darwin)
  TARGET = DaoOpenGL.dylib
  CFLAG += -DUNIX -DMAC_OSX
  LFLAG += -fPIC -dynamiclib -install_name libDaoOpenGL.dylib
  INCLUDE += -I/System/Library/Frameworks/OpenGL.framework/Headers
  LIB += -L/System/Library/Frameworks/OpenGL.framework/Libraries
  DIR_INPUT =/System/Library/Frameworks/OpenGL.framework/Headers
endif


BIND_CONFIG = dir_input=$(DIR_INPUT) dir_output=wrap $(DIR_INC) fixing=fixing.txt

first: all 

all: $(TARGET)

.SUFFIXES: .c .obj .cpp .cc .cxx .C

.c.o:
	$(CC) $(INCLUDE) -c $(CFLAGS) -o $@ $<

$(TARGET): wrap/dao_gl.o wrap/dao_gl2.o wrap/dao_gl3.o
	$(CC) $(LIB) $(LFLAG) -o $@ $<

clean:
	rm wrap/*.o

bind:
	autobind.dao gl.h $(BIND_CONFIG)
